﻿using System;
using System.Linq;
using System.Text;

namespace ReverseDecimalNumber
{
    class ReverseDecimalNumber
    {
        static string ReverseNumber(string number)
        {
            StringBuilder num = new StringBuilder(number);
            StringBuilder result = new StringBuilder();
            bool isNegative = number[0] == '-';
            int leadingZeroes = 0;

            if (isNegative)
            {
                num.Remove(0, 1);
            }

            for (int index = 0, length = num.Length - 1; index < length; index++) //if the number is 00001 => 1
            {
                if (num[index] == '0')
                {
                    leadingZeroes++;
                }
                else
                {
                    break;
                }
            }

            if (isNegative)
            {
                result.Append('-');
            }

            for (int index = num.Length - 1; index >= leadingZeroes; index--) //00000954 => 459
            {
                result.Append(num[index]);
            }

            return result.ToString();
        }

        static void Main()
        {
            Console.WriteLine(ReverseNumber("-0000321"));
        }
    }
}
